<?php

    require_once '../simpletest/autorun.php';
    require_once '../Common/Model/M_login.php';
    require_once '../Common/Model/DBConnection.php';
    
    class TestOfLogin extends UnitTestCase{

        public $db_connect;
        public $login;
        public $query;
        public $row;
        
        public function __construct()
    {
            $this->db_connect = new DB_Connection();
            $this->db_connect->connect();
            $this->login = new Com_Login();
            $this->query=  mysql_query("select * from admin_data where status = 1");
            $this->row=  mysql_fetch_array($this->query);
            $this->db_connect->disconnect();
    }
            
        /*
         * Test case to test correct username and password.
         * @return true
         */
        function test_correct_credential(){
            $correct_credential=$this->login->check_credential($this->row["username"], $this->row["password"]);
            $this->assertTrue($correct_credential);
        }
        
        /*
         * Test case to test incorrect username and password.
         * @return false
         */
        function test_incorrect_credential(){
            //$login = new Com_Login();
            $incorrect_credential=$this->login->check_credential($this->row["username"], "test");
            $this->assertFalse($incorrect_credential);
        }
    }
    
?>
